
package com.bs.regsystemapi.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

import static com.google.common.collect.Lists.newArrayList;

/**
 * @author ning
 * @date 2023/1/2 18:31
 * @desc 接口文档配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

    @Bean
    public Docket createRestApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("守护云健康管家系统")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.bs.regsystemapi.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;

    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("守护云健康管家系统-接口文档")
                .description("reg-system-api-master RESTful APIs")
                .termsOfServiceUrl("http://www.group.com/")
                .contact("宁秋梅")
                .version("1.0")
                .build();
    }

    private List<ApiKey> security() {
        return newArrayList(
            new ApiKey("token", "token", "header")
        );
    }


}